﻿<UserControl xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit"
             xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
             x:Class="predic.Web.Controls.MaintainPrediciControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:conv="clr-namespace:predic.Web.Converter"
             mc:Ignorable="d"
             x:Name="MasterControl"
             d:DesignHeight="300"
             d:DesignWidth="400"
             xmlns:local="clr-namespace:predic.Web.Controls">

    <UserControl.Resources>
        <conv:SummaryConverter x:Key="SummaryConv" />
    </UserControl.Resources>



    <toolkit:BusyIndicator IsBusy="{Binding Path=IsBusy}"
                           BusyContent="{Binding Path=BusyMessage}">
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>

            <!--<local:StudyInlineEditor Grid.Row="0" Visibility="{Binding Path=StudyInlineVisibility}">
                <local:StudyInlineEditor.Style>
                    <Style TargetType="local:StudyInlineEditor">
                        <Setter Property="Background" Value="White"/>
                    </Style>
                </local:StudyInlineEditor.Style>
            </local:StudyInlineEditor>-->

            <Grid x:Name="LayoutRoot" Grid.Row="1">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition />
                    <ColumnDefinition />
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="25" />
                    <RowDefinition Height="35" />

                    <RowDefinition Height="25" />
                    <RowDefinition Height="35" />

                    <RowDefinition Height="35" />

                    <RowDefinition Height="*" />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>

                <!--Predicator-->
                <TextBlock Text="Predicator"
                       Style="{StaticResource LabelBold}"
                       Grid.Column="0"
                       Margin="5"
                       Grid.Row="0"
                       VerticalAlignment="Center">
                </TextBlock>
                <sdk:AutoCompleteBox Grid.Column="0"
                                 ValueMemberPath="FullName"
                                 Text="{Binding Path=PreacherFullName, Mode=TwoWay}"
                                 SelectedItem="{Binding Path=SelectedPreacher, Mode=TwoWay, UpdateSourceTrigger=Default}"
                                 ItemsSource="{Binding Path=PreachersList}"
                                 Margin="5"
                                 Grid.Row="1" />

                <!--Titlu-->
                <TextBlock Text="Titlu"
                       Style="{StaticResource LabelBold}"
                       Grid.Column="1"
                       Margin="5"
                       Grid.Row="0"
                       VerticalAlignment="Center">
                </TextBlock>
                <sdk:AutoCompleteBox Grid.Column="1"
                                 Grid.Row="1"
                                 Margin="5"
                                 FilterMode="Contains"
                                 ItemsSource="{Binding Path=TitleList}"
                                 SelectedItem="{Binding Path=SelectedTitle, Mode=TwoWay, UpdateSourceTrigger=Default}"
                                 Text="{Binding Path=Title, Mode=TwoWay}"
                                 ValueMemberPath="CustomValue">
                    <sdk:AutoCompleteBox.ItemTemplate>
                        <DataTemplate>
                            <StackPanel>
                                <TextBlock Text="{Binding Path=CustomValue}" />
                            </StackPanel>
                        </DataTemplate>
                    </sdk:AutoCompleteBox.ItemTemplate>
                </sdk:AutoCompleteBox>

                <!--Subtitlu-->
                <TextBlock Text="Subtitlu"
                       Style="{StaticResource LabelBold}"
                       Grid.Column="2"
                       Margin="5"
                       Grid.Row="0"
                       VerticalAlignment="Center">
                </TextBlock>
                <sdk:AutoCompleteBox Grid.Column="2"
                                 Grid.Row="1"
                                 Margin="5"
                                 FilterMode="Contains"
                                 ValueMemberPath="CustomValue"
                                 Text="{Binding Path=Subtitle, Mode=TwoWay}"
                                 SelectedItem="{Binding Path=SelectedSubtitle, Mode=TwoWay, UpdateSourceTrigger=Default}"
                                 ItemsSource="{Binding Path=SubtitleList}">
                    <sdk:AutoCompleteBox.ItemTemplate>
                        <DataTemplate>
                            <StackPanel>
                                <TextBlock Text="{Binding Path=CustomValue}" />
                            </StackPanel>
                        </DataTemplate>
                    </sdk:AutoCompleteBox.ItemTemplate>
                </sdk:AutoCompleteBox>

                <!--Text-->
                <TextBlock Text="Text"
                       Style="{StaticResource LabelBold}"
                       Grid.Column="0"
                       Margin="5"
                       Grid.Row="2"
                       VerticalAlignment="Center">
                </TextBlock>
                <sdk:AutoCompleteBox Grid.Column="0"
                                 Grid.Row="3"
                                 Margin="5"
                                 ValueMemberPath="Text"
                                 Text="{Binding Path=Text, Mode=TwoWay}"
                                 ItemsSource="{Binding Path=StudyList}">
                    <sdk:AutoCompleteBox.ItemTemplate>
                        <DataTemplate>
                            <StackPanel>
                                <TextBlock Text="{Binding Path=Text}" />
                            </StackPanel>
                        </DataTemplate>
                    </sdk:AutoCompleteBox.ItemTemplate>
                </sdk:AutoCompleteBox>

                <!--Tematica-->
                <TextBlock Text="Tematica"
                       Style="{StaticResource LabelBold}"
                       Grid.Column="1"
                       Margin="5"
                       Grid.Row="2"
                       VerticalAlignment="Center">
                </TextBlock>
                <sdk:AutoCompleteBox Grid.Column="1"
                                 Grid.Row="3"
                                 Margin="5"
                                 ValueMemberPath="Tematica"
                                 Text="{Binding Path=Tematica, Mode=TwoWay}"
                                 ItemsSource="{Binding Path=StudyList}">
                    <sdk:AutoCompleteBox.ItemTemplate>
                        <DataTemplate>
                            <StackPanel>
                                <TextBlock Text="{Binding Path=Tematica}" />
                            </StackPanel>
                        </DataTemplate>
                    </sdk:AutoCompleteBox.ItemTemplate>
                </sdk:AutoCompleteBox>

                <!--Subiectul-->
                <TextBlock Text="Subiect"
                       Style="{StaticResource LabelBold}"
                       Grid.Column="2"
                       Margin="5"
                       Grid.Row="2"
                       VerticalAlignment="Center">
                </TextBlock>
                <sdk:AutoCompleteBox Grid.Column="2"
                                 Grid.Row="3"
                                 Margin="5"
                                 ValueMemberPath="Subiect"
                                 Text="{Binding Path=Subiect, Mode=TwoWay}"
                                 ItemsSource="{Binding Path=StudyList}">
                    <sdk:AutoCompleteBox.ItemTemplate>
                        <DataTemplate>
                            <StackPanel>
                                <TextBlock Text="{Binding Path=Subiect}" />
                            </StackPanel>
                        </DataTemplate>
                    </sdk:AutoCompleteBox.ItemTemplate>
                </sdk:AutoCompleteBox>

                <StackPanel Grid.ColumnSpan="3"
                        Margin="5"
                        VerticalAlignment="Center"
                        Grid.Row="4"
                        Orientation="Horizontal">
                    <Button Content="New"
                        Command="{Binding Path=NewCommand}"
                        Width="90" />
                    <Button Content="Save"
                        Width="90"
                        Command="{Binding Path=SaveCommand}"/>
                    <!--<Button Content="Delete"
                        Width="90" />-->

                    <!--<CheckBox Content="Audio"
                          Style="{StaticResource CheckBoxBold}" />
                <CheckBox Margin="5,0,0,0"
                          Style="{StaticResource CheckBoxBold}"
                          Content="Video" />-->
                </StackPanel>

                <sdk:DataGrid Grid.Row="5"
                          x:Name="GridStudy"
                          AutoGenerateColumns="False"
                          ItemsSource="{Binding Path=StudyListPaged}"
                          Margin="5,0,5,0"
                          Grid.ColumnSpan="3"
                          SelectionMode="Single"
                          Background="{x:Null}"
                          RowBackground="{StaticResource StudiuRowBackground}"
                          AreRowDetailsFrozen="True"
                          AlternatingRowBackground="{StaticResource StudiuRowBackground}">
                    <!--<sdk:DataGrid.Triggers>
                    <EventTrigger RoutedEvent="Grid.Loaded">
                        <EventTrigger.Actions>
                            <BeginStoryboard>
                                <Storyboard x:Name="fabeStoryboard">
                                    <DoubleAnimation Storyboard.TargetName="StudiuRowTemplateGrid"
                                                     Storyboard.TargetProperty="Opacity"
                                                     From="0.0"
                                                     To="1.0"
                                                     Duration="0:0:1" />
                                </Storyboard>
                            </BeginStoryboard>
                        </EventTrigger.Actions>
                    </EventTrigger>
                </sdk:DataGrid.Triggers>-->


                    <sdk:DataGrid.BorderBrush>
                        <LinearGradientBrush>
                            <GradientStop Color="#FFA3AEB9"
                                      Offset="0" />
                            <GradientStop Color="#FF8399A9"
                                      Offset="0.375" />
                            <GradientStop Color="#FF718597"
                                      Offset="0.375" />
                            <GradientStop Color="White"
                                      Offset="1" />
                        </LinearGradientBrush>
                    </sdk:DataGrid.BorderBrush>
                    <sdk:DataGrid.Columns>
                        <sdk:DataGridTextColumn  Width="*"
                                             Header="Titlu"
                                             Binding="{Binding Path=Title}"
                                             IsReadOnly="True" />

                        <sdk:DataGridTextColumn  Width="*"
                                             Header="Subtitlu"
                                             Binding="{Binding Path=Subtitle}"
                                             IsReadOnly="True" />

                        <sdk:DataGridTextColumn  Width="*"
                                             Header="Text"
                                             Binding="{Binding Path=Text}"
                                             IsReadOnly="True" />

                        <sdk:DataGridTextColumn  Width="*"
                                             Header="Tematica"
                                             Binding="{Binding Path=Tematica}"
                                             IsReadOnly="True" />

                        <sdk:DataGridTextColumn  Width="*"
                                             Header="Subiect"
                                             Binding="{Binding Path=Subiect}"
                                             IsReadOnly="True" />

                    </sdk:DataGrid.Columns>

                    <sdk:DataGrid.RowDetailsTemplate>
                        <DataTemplate>
                            <Grid Background="{StaticResource StudiuRowBackground}"
                              x:Name="StudiuRowTemplateGrid">

                                <Grid.RowDefinitions>
                                    <RowDefinition Height="40" />
                                    <RowDefinition Height="40" />
                                </Grid.RowDefinitions>

                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="*" />
                                    <ColumnDefinition Width="*" />
                                </Grid.ColumnDefinitions>

                                <TextBlock Grid.Row="0"
                                       Grid.Column="0"
                                       Grid.ColumnSpan="2"
                                       Text="{Binding Converter={StaticResource SummaryConv}}" />

                                <!--Source={Binding ElementName=MasterControl, Path=DataContext}, NotifyOnValidationError=True,ValidatesOnDataErrors=True}"-->

                                <StackPanel Grid.Column="0"
                                        Orientation="Horizontal"
                                        HorizontalAlignment="Left"
                                        Grid.Row="1">

                                    <Button Content="Edit"
                                        Width="90"
                                        Height="35"
                                        Click="Button_Click" />

                                    <Button Content="Delete"
                                        Width="90"
                                        Height="35"
                                        Click="Button_Click" />
                                </StackPanel>

                            </Grid>
                        </DataTemplate>
                    </sdk:DataGrid.RowDetailsTemplate>
                </sdk:DataGrid>

                <sdk:DataPager Grid.Row="6"
                           PageSize="15"
                           Source="{Binding Path=ItemsSource, ElementName=GridStudy}"
                           Margin="5,0,5,0"
                           Grid.ColumnSpan="3" />
            </Grid>
        </Grid>
    </toolkit:BusyIndicator>
</UserControl>
